package com.zzz.springbootdemo.controller;


import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/demo1")
public class Demo2_Request {
    @RequestMapping("/getinfo")
    public String getInfo(String info) {
        return info;
    }

    @RequestMapping(path = "/getinfo2/{name}/{age}")
    public String getinfo2(@PathVariable("name") String name, @PathVariable("age") String age) {
        return " i am " + name;
    }

    @RequestMapping("/getinfo3")
    public String getinfo3(@RequestParam(value = "name", required = true) String name) {
        String ss = "123";
        System.out.println("1");

        System.out.println(name);
        System.out.println("2");
        return ss;
    }

    @RequestMapping("/getinfo4")
    public String getinfo4(@RequestParam(value = "name", required = false) String name) {
        String ss = "123" + "111";
        System.out.println("1");
        System.out.println(name);
        System.out.println("2");

        return ss;
    }

    @RequestMapping("/getinfo5")
    public String getinfo5(@RequestParam(value = "name", required = true, defaultValue = "111") String name) {
        String ss = "123";
        System.out.println("1");
        System.out.println(name);
        System.out.println("2");
        return ss;
    }
}
